package org.classdef.analyzer.info.constant;

/**
 * 
 * 字符串类型常量信息
 *
 */
public class StringInfo extends ConstantInfo {
	private short stringIndex;

	public StringInfo(short tag, short stringIndex) {
		super(tag);
		this.stringIndex = stringIndex;
	}

	@Override
	public Object getValue() {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("\"class\":\"").append(String.class.getName()).append("\"");
		sb.append(",\"value\":\"").append(getPool().get(stringIndex).getValue())
				.append("\"");
		sb.append("}");
		return sb.toString();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("\"tag\":").append(tag);
		sb.append(",\"stringIndex\":").append(stringIndex);
		sb.append("}");
		return sb.toString();
	}
}